package gui.image;

import gui.popupmenu.PasteMouseAdaptor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

/**
 *
 * @author SUCCESS\quannguyen
 */
public class FolderImageList extends ImageList {

    public FolderImageList(File file, String name) {
        super(file, name);
        this.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent evt) {
                switch (evt.getButton()) {
                    case MouseEvent.BUTTON3:
                        JPopupMenu menu = new JPopupMenu();
                        JMenuItem item = new JMenuItem("Paste");
                        if (util.Clipboard.getInstance().getData() != null) {
                            item.addMouseListener(new PasteMouseAdaptor((FolderImageList) evt.getComponent()));
                        } else {
                            item.setEnabled(false);
                        }
                        menu.add(item);
                        menu.show(evt.getComponent(), evt.getX(), evt.getY());
                        break;
                }
            }
        });
    }

    @Override
    public void removeImage(ImagePanel imagePanel) throws IOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
